#include <bits/stdc++.h>
using namespace std;
const int cnt = (int)1e8;
inline int FastLog2(int x)
{
    float fx;
    unsigned long ix, exp;

    fx = (float)x;
    ix = (unsigned long&)fx;
    exp = (ix >> 23) & 0xFF;

    return exp - 127;
}
inline int FastLog22(float x)
{
    return ((unsigned &)x >> 23)-127; //（如果x可能为负，则移位后需要&0xFF）
}
inline int log2_fast(float d) {
    int result;
    std::frexp(d, &result);
    return result-1;
}

int main()
{

    time_t sa = clock();
    /*******************************/
    for (int i = 0; i < cnt; ++i) {
        FastLog2(i);
    }
    /*******************************/
    time_t ea = clock();
    cout << (double)(ea - sa)/CLOCKS_PER_SEC << "\n";




    time_t sb = clock();
    /*******************************/
    for (int i = 0; i < cnt; ++i) {
        log2_fast(i);
    }
    /*******************************/
    time_t eb = clock();
    cout << (double)(eb - sb)/CLOCKS_PER_SEC<< "\n";


    time_t sc = clock();
    /*******************************/
    for (int i = 0; i < cnt; ++i) {
        FastLog22(i);
    }
    /*******************************/
    time_t ec = clock();
    cout << (double)(ec - sc)/CLOCKS_PER_SEC << "\n";


    time_t sd = clock();
    /*******************************/
    for (int i = 0; i < cnt; ++i) {
        log2(i);
    }
    /*******************************/
    time_t ed = clock();
    cout << (double)(ed - sd)/CLOCKS_PER_SEC << "\n";
    return 0;
}
